<?php

namespace App\Models\IndexConfig\SearchRules;

use ScoutElastic\SearchRule;

class ProductDescriptionAutoCompleteSearchRule extends SearchRule
{
    /**
     * 自动补全只查 name 字段
     *
     * @link https://github.com/babenkoivan/scout-elasticsearch-driver#search-rules
     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
     *
     * @return array
     */
    public function buildQueryPayload()
    {
        return [
            'must' => [
                'match' => [
                    'name' => $this->builder->query
                ]
            ]
        ];
    }
}